<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <style>
        .content {
            width: 500px;
            height: 60px;
            margin: 100px auto;
            display: flex;
            justify-content: space-between;
            transition: all 500ms;
            margin-bottom: 0;
        }

        .content textarea {
            resize: none;
            width: 400px;
            margin-right: 10px;
            padding: 10px;
            /* height: 50px; */
        }

        .publish {
            width: 80px;
            background-color: dodgerblue;
            border: none;
            border-radius: 10px;
            color: white;
        }

        .focus {
            height: 100px;
            cursor: pointer;
        }

        .hint {
            width: 300px;
            text-align: right;
            margin: 0 auto;
            color: gray;
            font-size: 14px;
            display: none;
        }

    </style>
</head>
<body>

    <div class="content">
        <textarea name="comment" id="comment" placeholder="发一条友善的评论" maxlength="200"></textarea>
        <button class="publish">发布</button>
    </div>
    
    <div class="hint">
    </div>

<script>
    let text = document.querySelector(".content textarea")
    let content = document.querySelector(".content")
    let hint = document.querySelector(".hint")
    let send = document.querySelector("button")
    text.addEventListener("focus", function() {
        content.classList.add("focus")
        hint.innerHTML = `${text.value.length}/200字`
        hint.style.display = "block"
    })

    text.addEventListener("input", function() {
        hint.innerHTML = `${text.value.length}/200字`
    })

    text.addEventListener("blur", function() {
        content.classList.remove("focus")
        hint.style.display = "none"
    })

    send.addEventListener("click", function() {
        alert(text.value)
    })
</script>
</body>
</html>